// var redis = require('redis'),
//         client = redis.createClient();
//     client.on("error", function (err) {
//         console.log("Error " + err);
// });
//     console.log("Setting key1");
//     client.set("key1", "My string!", redis.print);
//     console.log("Getting key1");
//     client.get("key1", function (err, reply) {
//         console.log("Results for key1:");
//         console.log(reply);
//         client.end();
// });


// 2

// const redis = require('redis')
// const client = redis.createClient()

// client.on('error',err=>{
//     console.log('err', err)
// })

// console.log('Setting user hash')

// client.hset('user','username','johndoe')
// client.hset('user','firstname','john')
// client.hset('user','lastname','doe')

// client.hkeys('user',(err,resplies)=>{
//     console.log('results for user')
//     console.log(resplies.length + ' replies')
//     resplies.forEach((reply, i)=>{
//         console.log(i, ' : ' + reply)
//     })
//     client.end()
// })

//3
// var redis = require('redis'),
//         client = redis.createClient();
//     client.on("error", function (err) {
//         console.log("Error " + err);
// });
//     console.log("Setting user hash");
//     client.hmset("user", "username", "johndoe", "firstname", "john",
//     "lastname", "doe");
//     client.hkeys("user", function(err,replies) {
//         console.log("Results for user:");
//         console.log(replies.length + " replies:");
//         replies.forEach(function (reply, i) {
//             console.log(i + ": " + reply );
//         });
//         client.end();
//     });

var redis = require('redis'),
        client = redis.createClient();
    client.on("error", function (err) {
        console.log("Error " + err);
});
    client.lpush("pendingusers", "user1" );
    client.lpush("pendingusers", "user2" );
    client.lpush("pendingusers", "user3" );
    client.lpush("pendingusers", "user4" );
    client.rpop("pendingusers", function(err,username) {
      if( !err ) {
        console.log("Processing " + username);
      }
      client.end();
    });
